<?php

$uid = intval($_W['member']['uid']);
if ($op == 'index') {

    $data = pdo_fetch("SELECT * FROM " . tablename($this->table_lesson_cooperation) . " WHERE uid=:uid ", array(':uid' => $uid));
    if (!empty($data)) {
        header("Location:./index.php?i=3&c=entry&do=cooperation&op=data&m=fy_lessonv2");
    } else {
        include $this->template('cooperation');

    }


} elseif ($op == 'ajax') {

    $mobile = $_POST['mobile'];
    $nickname = $_POST['nickname'];
    $location = $_POST['location'];

    $addData = array('uid' => $uid, 'mobile' => $mobile, 'nickname' => $nickname, 'location_name' => $location);

    $addId = pdo_insert($this->table_lesson_cooperation, $addData);

    if ($addId) {
        exit(json_encode(array('code' => 200, 'msg' => '信息提交成功，待审核')));
    }

    exit(json_encode(array('code' => 500, 'msg' => '提交失败')));
} elseif ($op == 'data') {

    $data = pdo_fetch("SELECT * FROM " . tablename($this->table_lesson_cooperation) . " WHERE uid=:uid ", array(':uid' => $uid));
    if(empty($data)){
        header("Location:./index.php?i=3&c=entry&do=cooperation&op=index&m=fy_lessonv2");
    }
    include $this->template('cooperation');
}
?>